package com.wanmait.movie.controller;

import com.wanmait.movie.service.CinemaService;
import com.wanmait.movie.service.OrdersService;
import com.wanmait.movie.util.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("manage/order")
public class ManageOrderController {
    @Resource
    private OrdersService ordersService;
    @Resource
    private CinemaService cinemaService;

    @GetMapping("list")
    public AjaxResult list(Integer pageNum, Integer userId, Integer screeningId, Integer cinemaId, Integer lobbyId) {
        if (pageNum == null){
            pageNum = 1;
        }
        if (userId == null) {
            userId = 0;
        }
        if (screeningId == null) {
            screeningId = 0;
        }
        if (cinemaId == null) {
            cinemaId = 0;
        }
        if (lobbyId == null) {
            lobbyId = 0;
        }
        return AjaxResult.success(ordersService.getOrderList(pageNum, userId, screeningId, cinemaId, lobbyId)).put("cinemaList", cinemaService.getCinemaList());
    }

    @GetMapping("ordersDetailsList")
    public AjaxResult getOrdersDetailsList(String orderNumber) {
        return AjaxResult.success(ordersService.getOrdersDetailsListByOrderNumber(orderNumber));
    }
}
